package com.uranus.rancher.rancher.controller;


import com.uranus.common.VO.ServiceContext;
import com.uranus.common.VO.Result;
import com.uranus.common.constant.enums.LanguageEnum;
import com.uranus.rancher.rancher.beans.Rancher;
import com.uranus.rancher.rancher.service.RancherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author wei_yzh
 * @since 2018-12-10
 */

@RestController
@RequestMapping("/ranchers")
@Api(description = "Rancher Api 接口测试")
public class RancherController {

    @Autowired
    RancherService rancherService;

    @GetMapping
    @ApiOperation(value = "获取所有rancher集合")
    public Result getAll() {
        List<Rancher> list = rancherService.list();
        for (Rancher item :list){
            if(ServiceContext.getInstance().getLanguageEnum()== LanguageEnum.en_us){
                item.setRegion(item.getRegionEnUs());
            }
        }
        return Result.buildSuccess(list);
    }
//    @PostMapping("/search")
//    @ApiOperation(value = "search List")
//    public Result list(@RequestBody PagingRequest<RancherQueryRequest> request) {
//        return  rancherService.searchRancher(request);
//    }

}

